﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Negocio;
using System.Text;

namespace Presentacion.controlasistencia
{
    public partial class habilitar : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["admin"] != null)
                {
                    var habilitado = new Catalogo_Habilitado().consultar().FirstOrDefault();
                    StringBuilder html = new StringBuilder();
                    if (habilitado.estado == true)
                    {
                        LinkButton1.Visible = true;
                        LinkButton2.Visible = false;
                        html.Append("<div class='col-lg-4 col-sm-6'>" +
                            "<div class='circle-tile'>" +
                                "<a href = '#' >" +
                                    "<div class='circle-tile-heading green'>" +
                                        "<i class='fa fa-unlock'></i>" +
                                    "</div>" +
                                "</a>" +
                                "<div class='circle-tile-content green'>" +
                                    "<div class='circle-tile-description text-faded'>" +
                                        "ESTADO" +
                                    "</div>" +
                                    "<div class='circle-tile-number text-faded'>" +
                                        "HABILITADO" +
                                    "</div>" +
                                    "<a href ='#' class='circle-tile-footer'>More Info<i class='fa fa-chevron-circle-right'></i></a>" +
                                "</div>" +
                            "</div>" +
                        "</div>");
                    }
                    else
                    {
                        LinkButton1.Visible = false;
                        LinkButton2.Visible = true;
                        html.Append("<div class='col-lg-4 col-sm-6'>" +
                            "<div class='circle-tile'>" +
                                "<a href = '#' >" +
                                    "<div class='circle-tile-heading red'>" +
                                        "<i class='fa fa-unlock-alt'></i>" +
                                    "</div>" +
                                "</a>" +
                                "<div class='circle-tile-content red'>" +
                                    "<div class='circle-tile-description text-faded'>" +
                                        "ESTADO" +
                                    "</div>" +
                                    "<div class='circle-tile-number text-faded'>" +
                                        "INHABILITADO" +
                                    "</div>" +
                                    "<a href ='#' class='circle-tile-footer'>More Info<i class='fa fa-chevron-circle-right'></i></a>" +
                                "</div>" +
                            "</div>" +
                        "</div>");
                    }
                    estado.InnerHtml = html.ToString();
                }
                else
                {
                    Response.Redirect("Default.aspx");
                }
            }

        }

        #region INHABILITAR
        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            string mensaje = new Catalogo_Habilitado().habilitar(false);
            if (mensaje == "OK")
            {

                Response.Redirect("habilitar.aspx");
            }
            else
            {
                ClientScript.RegisterStartupScript(GetType(), "jsMensaje", "javascript:errorMessage('No se pudo inhabilitar la toma de asistencias. :(')", true);
            }
        }
        #endregion
        #region HABILITAR
        protected void LinkButton2_Click(object sender, EventArgs e)
        {
            string mensaje = new Catalogo_Habilitado().habilitar(true);
            if (mensaje == "OK")
            {

                Response.Redirect("habilitar.aspx");
            }
            else
            {
                ClientScript.RegisterStartupScript(GetType(), "jsMensaje", "javascript:errorMessage('No se pudo habilitar la toma de asistencias. :(')", true);
            }
        }

        #endregion


    }
}